package cn.virens.library.http;

import android.widget.ImageView;

import org.xutils.image.ImageOptions;

import cn.virens.library.R;
import cn.virens.library.activity.VApplication;


/**
 * Created by virens on 2016/11/22.
 */
public final class DefaultImage {
    private DefaultImage() {
    }

    /**
     * 获取图片相对服务器地址
     *
     * @param url
     * @return
     */
    public static final String image(String url) {
        return VApplication.image(url);
    }

    /**
     * 头像加载配置
     *
     * @return
     */
    public static ImageOptions defaultPortrait() {
        return new ImageOptions.Builder()
                .setCrop(true)
                .setLoadingDrawableId(R.mipmap.default_portrait)
                .setFailureDrawableId(R.mipmap.default_portrait)
                .build();
    }

    /**
     * 图片加载配置
     *
     * @return
     */
    public static ImageOptions defaultImage() {
        return new ImageOptions.Builder()
                .setCrop(true)
                .setLoadingDrawableId(R.mipmap.default_image)
                .setFailureDrawableId(R.mipmap.default_image)
                .build();
    }

    /**
     * 图片加载配置 - 平铺
     *
     * @return
     */
    public static ImageOptions defaultFitImage() {
        return new ImageOptions.Builder()
                .setCrop(true)
                .setLoadingDrawableId(R.mipmap.default_image)
                .setFailureDrawableId(R.mipmap.default_image)
                .setImageScaleType(ImageView.ScaleType.FIT_XY)
                .setPlaceholderScaleType(ImageView.ScaleType.FIT_XY)
                .build();
    }
}
